Conditions | 1 |
Paths | 0 |
Total Lines | 666 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /*! |
||
52 | ( function( jQuery, undefined ) { |
||
53 | |||
54 | var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " + |
||
55 | "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", |
||
56 | |||
57 | // Plusequals test for += 100 -= 100 |
||
58 | rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, |
||
59 | |||
60 | // A set of RE's that can match strings and generate color tuples. |
||
61 | stringParsers = [ { |
||
62 | re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
||
63 | parse: function( execResult ) { |
||
64 | return [ |
||
65 | execResult[ 1 ], |
||
66 | execResult[ 2 ], |
||
67 | execResult[ 3 ], |
||
68 | execResult[ 4 ] |
||
69 | ]; |
||
70 | } |
||
71 | }, { |
||
72 | re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
||
73 | parse: function( execResult ) { |
||
74 | return [ |
||
75 | execResult[ 1 ] * 2.55, |
||
76 | execResult[ 2 ] * 2.55, |
||
77 | execResult[ 3 ] * 2.55, |
||
78 | execResult[ 4 ] |
||
79 | ]; |
||
80 | } |
||
81 | }, { |
||
82 | |||
83 | // This regex ignores A-F because it's compared against an already lowercased string |
||
84 | re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, |
||
85 | parse: function( execResult ) { |
||
86 | return [ |
||
87 | parseInt( execResult[ 1 ], 16 ), |
||
88 | parseInt( execResult[ 2 ], 16 ), |
||
89 | parseInt( execResult[ 3 ], 16 ) |
||
90 | ]; |
||
91 | } |
||
92 | }, { |
||
93 | |||
94 | // This regex ignores A-F because it's compared against an already lowercased string |
||
95 | re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, |
||
96 | parse: function( execResult ) { |
||
97 | return [ |
||
98 | parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), |
||
99 | parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), |
||
100 | parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) |
||
101 | ]; |
||
102 | } |
||
103 | }, { |
||
104 | re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
||
105 | space: "hsla", |
||
106 | parse: function( execResult ) { |
||
107 | return [ |
||
108 | execResult[ 1 ], |
||
109 | execResult[ 2 ] / 100, |
||
110 | execResult[ 3 ] / 100, |
||
111 | execResult[ 4 ] |
||
112 | ]; |
||
113 | } |
||
114 | } ], |
||
115 | |||
116 | // JQuery.Color( ) |
||
117 | color = jQuery.Color = function( color, green, blue, alpha ) { |
||
118 | return new jQuery.Color.fn.parse( color, green, blue, alpha ); |
||
119 | }, |
||
120 | spaces = { |
||
121 | rgba: { |
||
122 | props: { |
||
123 | red: { |
||
124 | idx: 0, |
||
125 | type: "byte" |
||
126 | }, |
||
127 | green: { |
||
128 | idx: 1, |
||
129 | type: "byte" |
||
130 | }, |
||
131 | blue: { |
||
132 | idx: 2, |
||
133 | type: "byte" |
||
134 | } |
||
135 | } |
||
136 | }, |
||
137 | |||
138 | hsla: { |
||
139 | props: { |
||
140 | hue: { |
||
141 | idx: 0, |
||
142 | type: "degrees" |
||
143 | }, |
||
144 | saturation: { |
||
145 | idx: 1, |
||
146 | type: "percent" |
||
147 | }, |
||
148 | lightness: { |
||
149 | idx: 2, |
||
150 | type: "percent" |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 | }, |
||
155 | propTypes = { |
||
156 | "byte": { |
||
157 | floor: true, |
||
158 | max: 255 |
||
159 | }, |
||
160 | "percent": { |
||
161 | max: 1 |
||
162 | }, |
||
163 | "degrees": { |
||
164 | mod: 360, |
||
165 | floor: true |
||
166 | } |
||
167 | }, |
||
168 | support = color.support = {}, |
||
169 | |||
170 | // Element for support tests |
||
171 | supportElem = jQuery( "<p>" )[ 0 ], |
||
172 | |||
173 | // Colors = jQuery.Color.names |
||
174 | colors, |
||
175 | |||
176 | // Local aliases of functions called often |
||
177 | each = jQuery.each; |
||
178 | |||
179 | // Determine rgba support immediately |
||
180 | supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; |
||
181 | support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; |
||
182 | |||
183 | // Define cache name and alpha properties |
||
184 | // for rgba and hsla spaces |
||
185 | each( spaces, function( spaceName, space ) { |
||
186 | space.cache = "_" + spaceName; |
||
187 | space.props.alpha = { |
||
188 | idx: 3, |
||
189 | type: "percent", |
||
190 | def: 1 |
||
191 | }; |
||
192 | } ); |
||
193 | |||
194 | function clamp( value, prop, allowEmpty ) { |
||
195 | var type = propTypes[ prop.type ] || {}; |
||
196 | |||
197 | if ( value == null ) { |
||
198 | return ( allowEmpty || !prop.def ) ? null : prop.def; |
||
199 | } |
||
200 | |||
201 | // ~~ is an short way of doing floor for positive numbers |
||
202 | value = type.floor ? ~~value : parseFloat( value ); |
||
203 | |||
204 | // IE will pass in empty strings as value for alpha, |
||
205 | // which will hit this case |
||
206 | if ( isNaN( value ) ) { |
||
207 | return prop.def; |
||
208 | } |
||
209 | |||
210 | if ( type.mod ) { |
||
211 | |||
212 | // We add mod before modding to make sure that negatives values |
||
213 | // get converted properly: -10 -> 350 |
||
214 | return ( value + type.mod ) % type.mod; |
||
215 | } |
||
216 | |||
217 | // For now all property types without mod have min and max |
||
218 | return 0 > value ? 0 : type.max < value ? type.max : value; |
||
219 | } |
||
220 | |||
221 | function stringParse( string ) { |
||
222 | var inst = color(), |
||
223 | rgba = inst._rgba = []; |
||
224 | |||
225 | string = string.toLowerCase(); |
||
226 | |||
227 | each( stringParsers, function( i, parser ) { |
||
228 | var parsed, |
||
229 | match = parser.re.exec( string ), |
||
230 | values = match && parser.parse( match ), |
||
231 | spaceName = parser.space || "rgba"; |
||
232 | |||
233 | if ( values ) { |
||
|
|||
234 | parsed = inst[ spaceName ]( values ); |
||
235 | |||
236 | // If this was an rgba parse the assignment might happen twice |
||
237 | // oh well.... |
||
238 | inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; |
||
239 | rgba = inst._rgba = parsed._rgba; |
||
240 | |||
241 | // Exit each( stringParsers ) here because we matched |
||
242 | return false; |
||
243 | } |
||
244 | } ); |
||
245 | |||
246 | // Found a stringParser that handled it |
||
247 | if ( rgba.length ) { |
||
248 | |||
249 | // If this came from a parsed string, force "transparent" when alpha is 0 |
||
250 | // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) |
||
251 | if ( rgba.join() === "0,0,0,0" ) { |
||
252 | jQuery.extend( rgba, colors.transparent ); |
||
253 | } |
||
254 | return inst; |
||
255 | } |
||
256 | |||
257 | // Named colors |
||
258 | return colors[ string ]; |
||
259 | } |
||
260 | |||
261 | color.fn = jQuery.extend( color.prototype, { |
||
262 | parse: function( red, green, blue, alpha ) { |
||
263 | if ( red === undefined ) { |
||
264 | this._rgba = [ null, null, null, null ]; |
||
265 | return this; |
||
266 | } |
||
267 | if ( red.jquery || red.nodeType ) { |
||
268 | red = jQuery( red ).css( green ); |
||
269 | green = undefined; |
||
270 | } |
||
271 | |||
272 | var inst = this, |
||
273 | type = jQuery.type( red ), |
||
274 | rgba = this._rgba = []; |
||
275 | |||
276 | // More than 1 argument specified - assume ( red, green, blue, alpha ) |
||
277 | if ( green !== undefined ) { |
||
278 | red = [ red, green, blue, alpha ]; |
||
279 | type = "array"; |
||
280 | } |
||
281 | |||
282 | if ( type === "string" ) { |
||
283 | return this.parse( stringParse( red ) || colors._default ); |
||
284 | } |
||
285 | |||
286 | if ( type === "array" ) { |
||
287 | each( spaces.rgba.props, function( key, prop ) { |
||
288 | rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); |
||
289 | } ); |
||
290 | return this; |
||
291 | } |
||
292 | |||
293 | if ( type === "object" ) { |
||
294 | if ( red instanceof color ) { |
||
295 | each( spaces, function( spaceName, space ) { |
||
296 | if ( red[ space.cache ] ) { |
||
297 | inst[ space.cache ] = red[ space.cache ].slice(); |
||
298 | } |
||
299 | } ); |
||
300 | } else { |
||
301 | each( spaces, function( spaceName, space ) { |
||
302 | var cache = space.cache; |
||
303 | each( space.props, function( key, prop ) { |
||
304 | |||
305 | // If the cache doesn't exist, and we know how to convert |
||
306 | if ( !inst[ cache ] && space.to ) { |
||
307 | |||
308 | // If the value was null, we don't need to copy it |
||
309 | // if the key was alpha, we don't need to copy it either |
||
310 | if ( key === "alpha" || red[ key ] == null ) { |
||
311 | return; |
||
312 | } |
||
313 | inst[ cache ] = space.to( inst._rgba ); |
||
314 | } |
||
315 | |||
316 | // This is the only case where we allow nulls for ALL properties. |
||
317 | // call clamp with alwaysAllowEmpty |
||
318 | inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); |
||
319 | } ); |
||
320 | |||
321 | // Everything defined but alpha? |
||
322 | if ( inst[ cache ] && |
||
323 | jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { |
||
324 | |||
325 | // Use the default of 1 |
||
326 | inst[ cache ][ 3 ] = 1; |
||
327 | if ( space.from ) { |
||
328 | inst._rgba = space.from( inst[ cache ] ); |
||
329 | } |
||
330 | } |
||
331 | } ); |
||
332 | } |
||
333 | return this; |
||
334 | } |
||
335 | }, |
||
336 | is: function( compare ) { |
||
337 | var is = color( compare ), |
||
338 | same = true, |
||
339 | inst = this; |
||
340 | |||
341 | each( spaces, function( _, space ) { |
||
342 | var localCache, |
||
343 | isCache = is[ space.cache ]; |
||
344 | if ( isCache ) { |
||
345 | localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; |
||
346 | each( space.props, function( _, prop ) { |
||
347 | if ( isCache[ prop.idx ] != null ) { |
||
348 | same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); |
||
349 | return same; |
||
350 | } |
||
351 | } ); |
||
352 | } |
||
353 | return same; |
||
354 | } ); |
||
355 | return same; |
||
356 | }, |
||
357 | _space: function() { |
||
358 | var used = [], |
||
359 | inst = this; |
||
360 | each( spaces, function( spaceName, space ) { |
||
361 | if ( inst[ space.cache ] ) { |
||
362 | used.push( spaceName ); |
||
363 | } |
||
364 | } ); |
||
365 | return used.pop(); |
||
366 | }, |
||
367 | transition: function( other, distance ) { |
||
368 | var end = color( other ), |
||
369 | spaceName = end._space(), |
||
370 | space = spaces[ spaceName ], |
||
371 | startColor = this.alpha() === 0 ? color( "transparent" ) : this, |
||
372 | start = startColor[ space.cache ] || space.to( startColor._rgba ), |
||
373 | result = start.slice(); |
||
374 | |||
375 | end = end[ space.cache ]; |
||
376 | each( space.props, function( key, prop ) { |
||
377 | var index = prop.idx, |
||
378 | startValue = start[ index ], |
||
379 | endValue = end[ index ], |
||
380 | type = propTypes[ prop.type ] || {}; |
||
381 | |||
382 | // If null, don't override start value |
||
383 | if ( endValue === null ) { |
||
384 | return; |
||
385 | } |
||
386 | |||
387 | // If null - use end |
||
388 | if ( startValue === null ) { |
||
389 | result[ index ] = endValue; |
||
390 | } else { |
||
391 | if ( type.mod ) { |
||
392 | if ( endValue - startValue > type.mod / 2 ) { |
||
393 | startValue += type.mod; |
||
394 | } else if ( startValue - endValue > type.mod / 2 ) { |
||
395 | startValue -= type.mod; |
||
396 | } |
||
397 | } |
||
398 | result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); |
||
399 | } |
||
400 | } ); |
||
401 | return this[ spaceName ]( result ); |
||
402 | }, |
||
403 | blend: function( opaque ) { |
||
404 | |||
405 | // If we are already opaque - return ourself |
||
406 | if ( this._rgba[ 3 ] === 1 ) { |
||
407 | return this; |
||
408 | } |
||
409 | |||
410 | var rgb = this._rgba.slice(), |
||
411 | a = rgb.pop(), |
||
412 | blend = color( opaque )._rgba; |
||
413 | |||
414 | return color( jQuery.map( rgb, function( v, i ) { |
||
415 | return ( 1 - a ) * blend[ i ] + a * v; |
||
416 | } ) ); |
||
417 | }, |
||
418 | toRgbaString: function() { |
||
419 | var prefix = "rgba(", |
||
420 | rgba = jQuery.map( this._rgba, function( v, i ) { |
||
421 | return v == null ? ( i > 2 ? 1 : 0 ) : v; |
||
422 | } ); |
||
423 | |||
424 | if ( rgba[ 3 ] === 1 ) { |
||
425 | rgba.pop(); |
||
426 | prefix = "rgb("; |
||
427 | } |
||
428 | |||
429 | return prefix + rgba.join() + ")"; |
||
430 | }, |
||
431 | toHslaString: function() { |
||
432 | var prefix = "hsla(", |
||
433 | hsla = jQuery.map( this.hsla(), function( v, i ) { |
||
434 | if ( v == null ) { |
||
435 | v = i > 2 ? 1 : 0; |
||
436 | } |
||
437 | |||
438 | // Catch 1 and 2 |
||
439 | if ( i && i < 3 ) { |
||
440 | v = Math.round( v * 100 ) + "%"; |
||
441 | } |
||
442 | return v; |
||
443 | } ); |
||
444 | |||
445 | if ( hsla[ 3 ] === 1 ) { |
||
446 | hsla.pop(); |
||
447 | prefix = "hsl("; |
||
448 | } |
||
449 | return prefix + hsla.join() + ")"; |
||
450 | }, |
||
451 | toHexString: function( includeAlpha ) { |
||
452 | var rgba = this._rgba.slice(), |
||
453 | alpha = rgba.pop(); |
||
454 | |||
455 | if ( includeAlpha ) { |
||
456 | rgba.push( ~~( alpha * 255 ) ); |
||
457 | } |
||
458 | |||
459 | return "#" + jQuery.map( rgba, function( v ) { |
||
460 | |||
461 | // Default to 0 when nulls exist |
||
462 | v = ( v || 0 ).toString( 16 ); |
||
463 | return v.length === 1 ? "0" + v : v; |
||
464 | } ).join( "" ); |
||
465 | }, |
||
466 | toString: function() { |
||
467 | return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); |
||
468 | } |
||
469 | } ); |
||
470 | color.fn.parse.prototype = color.fn; |
||
471 | |||
472 | // Hsla conversions adapted from: |
||
473 | // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 |
||
474 | |||
475 | function hue2rgb( p, q, h ) { |
||
476 | h = ( h + 1 ) % 1; |
||
477 | if ( h * 6 < 1 ) { |
||
478 | return p + ( q - p ) * h * 6; |
||
479 | } |
||
480 | if ( h * 2 < 1 ) { |
||
481 | return q; |
||
482 | } |
||
483 | if ( h * 3 < 2 ) { |
||
484 | return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; |
||
485 | } |
||
486 | return p; |
||
487 | } |
||
488 | |||
489 | spaces.hsla.to = function( rgba ) { |
||
490 | if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { |
||
491 | return [ null, null, null, rgba[ 3 ] ]; |
||
492 | } |
||
493 | var r = rgba[ 0 ] / 255, |
||
494 | g = rgba[ 1 ] / 255, |
||
495 | b = rgba[ 2 ] / 255, |
||
496 | a = rgba[ 3 ], |
||
497 | max = Math.max( r, g, b ), |
||
498 | min = Math.min( r, g, b ), |
||
499 | diff = max - min, |
||
500 | add = max + min, |
||
501 | l = add * 0.5, |
||
502 | h, s; |
||
503 | |||
504 | if ( min === max ) { |
||
505 | h = 0; |
||
506 | } else if ( r === max ) { |
||
507 | h = ( 60 * ( g - b ) / diff ) + 360; |
||
508 | } else if ( g === max ) { |
||
509 | h = ( 60 * ( b - r ) / diff ) + 120; |
||
510 | } else { |
||
511 | h = ( 60 * ( r - g ) / diff ) + 240; |
||
512 | } |
||
513 | |||
514 | // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0% |
||
515 | // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) |
||
516 | if ( diff === 0 ) { |
||
517 | s = 0; |
||
518 | } else if ( l <= 0.5 ) { |
||
519 | s = diff / add; |
||
520 | } else { |
||
521 | s = diff / ( 2 - add ); |
||
522 | } |
||
523 | return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ]; |
||
524 | }; |
||
525 | |||
526 | spaces.hsla.from = function( hsla ) { |
||
527 | if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { |
||
528 | return [ null, null, null, hsla[ 3 ] ]; |
||
529 | } |
||
530 | var h = hsla[ 0 ] / 360, |
||
531 | s = hsla[ 1 ], |
||
532 | l = hsla[ 2 ], |
||
533 | a = hsla[ 3 ], |
||
534 | q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, |
||
535 | p = 2 * l - q; |
||
536 | |||
537 | return [ |
||
538 | Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), |
||
539 | Math.round( hue2rgb( p, q, h ) * 255 ), |
||
540 | Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), |
||
541 | a |
||
542 | ]; |
||
543 | }; |
||
544 | |||
545 | each( spaces, function( spaceName, space ) { |
||
546 | var props = space.props, |
||
547 | cache = space.cache, |
||
548 | to = space.to, |
||
549 | from = space.from; |
||
550 | |||
551 | // Makes rgba() and hsla() |
||
552 | color.fn[ spaceName ] = function( value ) { |
||
553 | |||
554 | // Generate a cache for this space if it doesn't exist |
||
555 | if ( to && !this[ cache ] ) { |
||
556 | this[ cache ] = to( this._rgba ); |
||
557 | } |
||
558 | if ( value === undefined ) { |
||
559 | return this[ cache ].slice(); |
||
560 | } |
||
561 | |||
562 | var ret, |
||
563 | type = jQuery.type( value ), |
||
564 | arr = ( type === "array" || type === "object" ) ? value : arguments, |
||
565 | local = this[ cache ].slice(); |
||
566 | |||
567 | each( props, function( key, prop ) { |
||
568 | var val = arr[ type === "object" ? key : prop.idx ]; |
||
569 | if ( val == null ) { |
||
570 | val = local[ prop.idx ]; |
||
571 | } |
||
572 | local[ prop.idx ] = clamp( val, prop ); |
||
573 | } ); |
||
574 | |||
575 | if ( from ) { |
||
576 | ret = color( from( local ) ); |
||
577 | ret[ cache ] = local; |
||
578 | return ret; |
||
579 | } else { |
||
580 | return color( local ); |
||
581 | } |
||
582 | }; |
||
583 | |||
584 | // Makes red() green() blue() alpha() hue() saturation() lightness() |
||
585 | each( props, function( key, prop ) { |
||
586 | |||
587 | // Alpha is included in more than one space |
||
588 | if ( color.fn[ key ] ) { |
||
589 | return; |
||
590 | } |
||
591 | color.fn[ key ] = function( value ) { |
||
592 | var vtype = jQuery.type( value ), |
||
593 | fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), |
||
594 | local = this[ fn ](), |
||
595 | cur = local[ prop.idx ], |
||
596 | match; |
||
597 | |||
598 | if ( vtype === "undefined" ) { |
||
599 | return cur; |
||
600 | } |
||
601 | |||
602 | if ( vtype === "function" ) { |
||
603 | value = value.call( this, cur ); |
||
604 | vtype = jQuery.type( value ); |
||
605 | } |
||
606 | if ( value == null && prop.empty ) { |
||
607 | return this; |
||
608 | } |
||
609 | if ( vtype === "string" ) { |
||
610 | match = rplusequals.exec( value ); |
||
611 | if ( match ) { |
||
612 | value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); |
||
613 | } |
||
614 | } |
||
615 | local[ prop.idx ] = value; |
||
616 | return this[ fn ]( local ); |
||
617 | }; |
||
618 | } ); |
||
619 | } ); |
||
620 | |||
621 | // Add cssHook and .fx.step function for each named hook. |
||
622 | // accept a space separated string of properties |
||
623 | color.hook = function( hook ) { |
||
624 | var hooks = hook.split( " " ); |
||
625 | each( hooks, function( i, hook ) { |
||
626 | jQuery.cssHooks[ hook ] = { |
||
627 | set: function( elem, value ) { |
||
628 | var parsed, curElem, |
||
629 | backgroundColor = ""; |
||
630 | |||
631 | if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || |
||
632 | ( parsed = stringParse( value ) ) ) ) { |
||
633 | value = color( parsed || value ); |
||
634 | if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { |
||
635 | curElem = hook === "backgroundColor" ? elem.parentNode : elem; |
||
636 | while ( |
||
637 | ( backgroundColor === "" || backgroundColor === "transparent" ) && |
||
638 | curElem && curElem.style |
||
639 | ) { |
||
640 | try { |
||
641 | backgroundColor = jQuery.css( curElem, "backgroundColor" ); |
||
642 | curElem = curElem.parentNode; |
||
643 | } catch ( e ) { |
||
644 | } |
||
645 | } |
||
646 | |||
647 | value = value.blend( backgroundColor && backgroundColor !== "transparent" ? |
||
648 | backgroundColor : |
||
649 | "_default" ); |
||
650 | } |
||
651 | |||
652 | value = value.toRgbaString(); |
||
653 | } |
||
654 | try { |
||
655 | elem.style[ hook ] = value; |
||
656 | } catch ( e ) { |
||
657 | |||
658 | // Wrapped to prevent IE from throwing errors on "invalid" values like |
||
659 | // 'auto' or 'inherit' |
||
660 | } |
||
661 | } |
||
662 | }; |
||
663 | jQuery.fx.step[ hook ] = function( fx ) { |
||
664 | if ( !fx.colorInit ) { |
||
665 | fx.start = color( fx.elem, hook ); |
||
666 | fx.end = color( fx.end ); |
||
667 | fx.colorInit = true; |
||
668 | } |
||
669 | jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); |
||
670 | }; |
||
671 | } ); |
||
672 | |||
673 | }; |
||
674 | |||
675 | color.hook( stepHooks ); |
||
676 | |||
677 | jQuery.cssHooks.borderColor = { |
||
678 | expand: function( value ) { |
||
679 | var expanded = {}; |
||
680 | |||
681 | each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { |
||
682 | expanded[ "border" + part + "Color" ] = value; |
||
683 | } ); |
||
684 | return expanded; |
||
685 | } |
||
686 | }; |
||
687 | |||
688 | // Basic color names only. |
||
689 | // Usage of any of the other color names requires adding yourself or including |
||
690 | // jquery.color.svg-names.js. |
||
691 | colors = jQuery.Color.names = { |
||
692 | |||
693 | // 4.1. Basic color keywords |
||
694 | aqua: "#00ffff", |
||
695 | black: "#000000", |
||
696 | blue: "#0000ff", |
||
697 | fuchsia: "#ff00ff", |
||
698 | gray: "#808080", |
||
699 | green: "#008000", |
||
700 | lime: "#00ff00", |
||
701 | maroon: "#800000", |
||
702 | navy: "#000080", |
||
703 | olive: "#808000", |
||
704 | purple: "#800080", |
||
705 | red: "#ff0000", |
||
706 | silver: "#c0c0c0", |
||
707 | teal: "#008080", |
||
708 | white: "#ffffff", |
||
709 | yellow: "#ffff00", |
||
710 | |||
711 | // 4.2.3. "transparent" color keyword |
||
712 | transparent: [ null, null, null, 0 ], |
||
713 | |||
714 | _default: "#ffffff" |
||
715 | }; |
||
716 | |||
717 | } )( jQuery ); |
||
718 | |||
1636 |
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.